Модуль:Инфобокс
local infobox = {} --эффективность function infobox.pick(frame) if frame.args1 "" then return else local pPickaxe = 0 local pAxe = 0 local pHammer = 0 local pick = mw.text.split(frame.args1, " ") for i = 1, 3 do if picki then local pType = mw.text.split(picki, "-") if pType1 "к" then pPickaxe = pType2 elseif pType1 "т" then pAxe = pType2 elseif pType1 "м" then pHammer = pType2 end end end return "link="..pPickaxe.."% link="..pAxe.."% link="..pHammer.."%" end end --тип function infobox.types(frame) local content = "" local args = mw.text.split(frame.args1, ", ") local typesLibrary = mw.loadData("Модуль:Инфобокс/Типы_-_"..frame.args2) for i = 1, #args do local lType = mw.ustring.lower(argsi) if i ~= 1 then content = content..", " end if typesLibrarylType then content = content.."[["..typesLibrarylType"статья".."|"..typesLibrarylType"название".."]] [[Категория:"..typesLibrarylType"категория".."]]" else content = content.."Неизвестный" end end return content end --урон function infobox.damage(frame) function determinationAttackType(atType, itTypes) if atType ~= "" then return atType end local types = mw.text.split(itTypes, ", ") local typesLibrary = mw.loadData("Модуль:Инфобокс/Типы_-_предмет") for i = 1, #types do if typesLibrary[typesi] and typesLibrary[typesi]урона" then return typesLibrary[typesi]урона" end end return "none" end local attack1 = tonumber(frame.args1) local attack2 = tonumber(frame.args2) local attackFactor1 = tonumber(frame.args3) local attackFactor2 = tonumber(frame.args4) local attackSpees1 = tonumber(frame.args5) local attackSpeed2 = tonumber(frame.args6) local attacktype = determinationAttackType(frame.args7, frame.args8) local content = "" if attack1 ~= 0 and attack2 ~= 0 then content = content..""..attack1.." + "..attack2.."" end if attacktype "ближний" then content = content.." 16px|link=" elseif attacktype "дальний" then content = content.." 8px|link=" elseif attacktype "магический" then content = content.." 16px|link=" elseif attacktype "прислужники" then content = content.." 16px|link=" elseif attacktype "метательный" then content = content.." 16px|link=" elseif attacktype "взрыв" then content = content.." 6px|link=" else content = content.."t" end return content end --размеры крюка function infobox.hook(frame) function wordsDeclination(word, number, end1, end2, end3) local lastSymbol = tonumber(mw.ustring.sub(number, -1)) local penultimateSymbol if mw.ustring.len(number) > 1 then penultimateSymbol = tonumber(mw.ustring.sub(number, -1, -2)) else penultimateSymbol = 0 end if lastSymbol 1 and penultimateSymbol ~= 1 then return word..end1 elseif lastSymbol > 1 and lastSymbol < 5 and penultimateSymbol ~= 1 then return word..end2 else return word..end3 end end local pHook = mw.text.split(frame.args1, "*") if #pHook 1 then return "1 ветвь в "..pHook1.." "..wordsDeclination("блок", pHook1, "", "а", "ов") else return pHook1.." "..wordsDeclination("ветв", pHook1, "ь", "и", "ей").." по "..pHook2.." "..wordsDeclination("блок", pHook2, "", "а", "ов") end end --цена function infobox.cost(frame) function coinCreate(coins, number, imageName) if tonumber(number) ~= 0 then if coins ~= '' then coins = coins.." " end coins = coins..number.." link=" end return coins end local content = "" if frame.args1 "none,sell" or frame.args1 "0,0,0,0,buy" or frame.args1 "0,0,0,0,sell" then content = "Отсутствует" else local price = mw.text.split(frame.args1, ",") if price5 "sell" then content = coinCreate(content, price1, "Platinum coin.png") content = coinCreate(content, price2, "Gold coin.png") content = coinCreate(content, price3, "Silver coin.png") content = coinCreate(content, price4, "Copper coin.png") elseif price5 "buy" then local buy = "" local sell = "" buy = coinCreate(buy, price1, "Platinum coin.png") buy = coinCreate(buy, price2, "Gold coin.png") buy = coinCreate(buy, price3, "Silver coin.png") buy = coinCreate(buy, price4, "Copper coin.png") local copperPrice = price1 * 1000000 + price2 * 10000 + price3 * 100 + price4 local sellCopperPrice if tonumber(copperPrice) <= 5 then sellCopperPrice = 1 else sellCopperPrice = math.floor(copperPrice / 5) end sellPrice = {} local lastCoins = 0 local exponent = 6 for i = 1, 4 do sellPricei = math.floor(sellCopperPrice / (10^exponent)) sellCopperPrice = sellCopperPrice - sellPricei * (10^exponent) exponent = exponent - 2 end sell = coinCreate(sell, sellPrice1, "Platinum coin.png") sell = coinCreate(sell, sellPrice2, "Gold coin.png") sell = coinCreate(sell, sellPrice3, "Silver coin.png") sell = coinCreate(sell, sellPrice4, "Copper coin.png") content = ""..buy.." / "..sell.."" end end return content end function infobox.costName(frame) local content = "" if frame.args1 "none,sell" or frame.args1 "0,0,0,0,buy" or frame.args1 "0,0,0,0,sell" then content = "Цена" else local price = mw.text.split(frame.args1, ",") if price5 "sell" then content = "Цена продажи" elseif price5 "buy" then content = "Цены" end end return content end return infobox